package com.mycms.module.index.service;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mycms.domain.Admin;
import com.mycms.domain.Login;
import com.mycms.module.index.dao.AdminIndexDao;
import com.mycms.util.EncryptUtil;

@Service
public class AdminIndexService {
	
	@Autowired
	AdminIndexDao adminIndexDao;
	
	/**
	 * 로그인
	 * 
	 * @param member
	 */
	public Admin login(Login login) {
		Admin resultVal = null;
		try {
			login.setLoginPsw(EncryptUtil.encryptSha256(login.getLoginPsw()));
			
			resultVal = adminIndexDao.login(login);
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		
		return resultVal;
	}
}
